<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <ul id="list"></ul>
  <script>
    var arr = [
      { "name": "小明", "age": 12, "sex": "男" },
      { "name": "小红", "age": 11, "sex": "女" },
      { "name": "小强", "age": 13, "sex": "男" }
    ]

    var list = document.getElementById('list')

    for (var i = 0; i < arr.length; i++) {
      // 每遍历一项 都要用DOM方法去创建li标签
      let oLi = document.createElement('li')
      // 创建hd这个div
      let hdDiv = document.createElement('div')
      hdDiv.className = 'hd'
      hdDiv.innerText = arr[i].name + '的基本信息'

      let bdDiv = document.createElement('div')
      bdDiv.className = 'bd'
      let p1 = document.createElement('p')
      p1.innerText = '姓名：' + arr[i].name
      let p2 = document.createElement('p')
      p2.innerText = '年龄：' + arr[i].age
      let p3 = document.createElement('p')
      p3.innerText = '性别：' + arr[i].sex

      // 创建的节点是孤儿节点 所以必须要上树才能被用户看见
      oLi.appendChild(hdDiv)
      oLi.appendChild(bdDiv)
      bdDiv.appendChild(p1)
      bdDiv.appendChild(p2)
      bdDiv.appendChild(p3)
      // 创建的节点是孤儿节点 所以必须要上树才能被用户看见
      list.appendChild(oLi)
    } 
  </script>
</body>
</html>